package com.ngc.mall.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ngc.mall.common.configure.mybatisPlus.BaseServiceImpl;
import com.ngc.mall.domain.UserIntegralTaskDomain;
import com.ngc.mall.mapper.UserIntegralTaskMapper;
import com.ngc.mall.service.IUserIntegralTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * 积分任务实现类
 * @author: chenxiaolin
 * @date 2023/9/12 12:22
**/
@Service
public class UserIntegralTaskServiceImpl extends BaseServiceImpl<UserIntegralTaskMapper, UserIntegralTaskDomain> implements IUserIntegralTaskService {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @Override
    public Long createTask(UserIntegralTaskDomain domain) {
        return super.create(domain);
    }

    @Override
    public Boolean updateById(Long id, UserIntegralTaskDomain domain) {
        return super.update(domain,Wrappers.<UserIntegralTaskDomain>lambdaQuery().eq(UserIntegralTaskDomain::getId,id));
    }

    @Override
    public Boolean deleteById(Long id) {
        return super.removeById(id);
    }

    @Override
    public Boolean updateStatusById(Long id, boolean status) {
        return super.update(Wrappers.<UserIntegralTaskDomain>lambdaUpdate().eq(UserIntegralTaskDomain::getId,id).set(UserIntegralTaskDomain::getIsEnabled,status));
    }

    @Override
    public List<UserIntegralTaskDomain> selectAll() {
        return super.list();
    }

    @Override
    public List<UserIntegralTaskDomain> selectAllShow() {
        return super.list(Wrappers.<UserIntegralTaskDomain>lambdaQuery().eq(UserIntegralTaskDomain::getIsEnabled,true));
    }


}
